﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="atm3", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(Atm3))]
    public class Atm3Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IAtm3 clazz;
        
        public Atm3Serializer(IAtm3 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Document!=null) {
                Writer.WriteStartElement("document");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "base64Binary");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBase64Binary(((byte[])(clazz.Document))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="document") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm3>document");
                }
                clazz.Document = new global::Xtee.Core.Schema.XsdBase64Binary(Reader.ReadElementString("document")).Value;
            }
        }
    }
}
